class ServiceException(Exception):
    """服务层异常基类"""
    def __init__(self, message: str, code: int = 400):
        self.code = code
        self.message = message
        super().__init__(message)

class NotFoundException(ServiceException):
    """资源未找到异常"""
    def __init__(self, message: str = "Resource not found"):
        super().__init__(message, 404)

class ValidationException(ServiceException):
    """数据验证异常"""
    def __init__(self, message: str = "Invalid data"):
        super().__init__(message, 422)